package com.dbs.donatebooksystem.controller;

import com.dbs.donatebooksystem.Service.ProductService;
import com.dbs.donatebooksystem.pojo.Result;
import com.dbs.donatebooksystem.pojo.product;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@CrossOrigin(origins = "http://localhost:8080",originPatterns = "http://localhost:8081")
public class ProductController {
    @Autowired
    private ProductService productService;

    @GetMapping("/selectProduct")
    public Result selectProduct(){
        log.info("查询商品");
        List<product> list = productService.selectAllProduct();
        return Result.success(list);
    }

    @PostMapping("/updateProduct")
    public Result updateProduct(@RequestBody product product){
        log.info("修改商品信息,{}",product);
        productService.updateProduct(product);
        return Result.success("修改成功");
    }

}
